home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lantools / blueprnt / bpsemaph.pas < prev    next >
Pascal/Delphi Source File  |  1989-10-24  |  2KB  |  62 lines

  1. program change_server_semaphore;
  2. (*************************************************************
  3. * Change Semaphore on BP-LAN Server                          *
  4. * by Craig Chaiken              (BPSEMAPH.PAS, BPSEMAPH.EXE) *                             *
  5. * October 24, 1989                                           *
  6. *                                                            *
  7. * Function:                                                  *
  8. *     This program attempts to change the specified          *
  9. *     semaphore on the server, in the manner indicated by    *
  10. *     the first command line parameter.  If the change is    *
  11. *     unsuccessful, a value of 255 is returned in the DOS    *
  12. *     ERRORLEVEL Variable, which is available from any       *
  13. *     batch file.                                            *
  14. *                                                            *
  15. * Command Format:                                            *
  16. *     BPSEMAPH /socket_number /semaphore_number /change      *
  17. *************************************************************)
  18. uses dos;
  19. {$I bppascal.inc}
  20. var
  21.     semaphore_number:byte;
  22.  
  23. procedure change_semaphore;
  24. {********************************}
  25. {*** Lock Specified Semaphore ***}
  26. {********************************}
  27. var
  28.     temp_string:string;
  29. begin
  30.     {*** Make Semaphore Change Request ***}
  31.     temp_string:=paramstr(3);
  32.     packet_buffer[0]:=ord(upcase(temp_string[2]));
  33.     packet_buffer[1]:=semaphore_number;
  34.     packet_length:=2;
  35.     put_packet(socket_number);
  36.  
  37.     {*** Receive Success Status ***}
  38.     packet_length:=get_packet(socket_number);
  39.  
  40.     {*** Exit to DOS, Setting DOS ERRORLEVEL Variable ***}
  41.     if packet_buffer[1]<>0 then
  42.         exit_with_error(255);
  43. end;
  44.  
  45.  
  46. begin
  47.     socket_number:=get_opt(1);
  48.     semaphore_number:=get_opt(2);
  49.     if ((paramstr(3)='/LOCK') or (paramstr(3)='/lock') or
  50.          (paramstr(3)='/UNLOCK') or (paramstr(3)='/unlock') or
  51.         (paramstr(3)='/CLEAR') or (paramstr(3)='/clear')) then
  52.           change_semaphore
  53.     else
  54.      begin
  55.         writeln('Syntax: BPSEMAPH /socket_number /semaphore_number ',
  56.             '/semaphore_change_switch');
  57.         writeln('''',paramstr(3),'''',
  58.         ' Unsupported Semaphore Change Switch!');
  59.         writeln('Supported Switches: /LOCK, /UNLOCK, and /CLEAR')
  60.     end;
  61. end.
  62.